﻿using System;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Configuration;

using SBPweb.PROvibe.Business.Shared.Contracts.Content;

namespace SBPweb.PROvibe.Business.Server.Library.Providers
{

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class LayoutProvider : ILayoutProvider
    {

        public ContentItemDescriptor GetLayoutRootItem(string url)
        {
            TypeDescriptor tD = new TypeDescriptor( "http://" + ConfigurationSettings.AppSettings["dnsSafeHost"] + "/ClientBin/SBPweb.PROvibe.Modules.Client.Navigator.xap",
                                                    "SBPweb.PROvibe.Modules.Client.Navigator.dll",
                                                    "SBPweb.PROvibe.Modules.Client.Navigator.Pages.Main");
            ContainerDescriptor cD = new ContainerDescriptor(ContainerIdConstants.RootVisual);
            ContentItemDescriptor cI = new ContentItemDescriptor(tD, cD);

            TypeDescriptor tD0 = new TypeDescriptor("http://" + ConfigurationSettings.AppSettings["dnsSafeHost"] + "/ClientBin/SBPweb.PROvibe.Modules.Client.Communication.Xmpp.xap",
                                                    "SBPweb.PROvibe.Modules.Client.Communication.Xmpp.dll",
                                                    "SBPweb.PROvibe.Modules.Client.Communication.Xmpp.Controls.MessengerMainPanel");
            ContainerDescriptor cD0 = new ContainerDescriptor(ContainerIdConstants.OverlayPanel);
            ContentItemDescriptor cI0 = new ContentItemDescriptor(tD0, cD0);

            cI.Children.Add(cI0);

            return cI;
        }

        public TypeDescriptor GetLayoutTheme(string url)
        {
            string themeName = "PROvibe";
            TypeDescriptor tD = new TypeDescriptor( "http://" + ConfigurationSettings.AppSettings["dnsSafeHost"] + "/ClientBin/SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".xap",
                                                    "SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".dll",
                                                    "SBPweb.PROvibe.Modules.Client.Themes." + themeName + ".Styles");

            return tD;
        }

    }

    [ServiceContract(Namespace = "providers.provibe.sbpweb.hu")]
    public interface ILayoutProvider : SBPweb.PROvibe.Business.Shared.Contracts.Providers.ILayoutProvider
    {

        [OperationContract]
        new ContentItemDescriptor GetLayoutRootItem(string url);

        [OperationContract]
        new TypeDescriptor GetLayoutTheme(string url);

    }

}